<script>
    var page_list = "news_list";
    $(function() {
        $("body").layout();
        grid_init($("#grid"),{
            singleSelect: false,
            columns:[[
                { field: 'o.id', checkbox: true, title: '新闻ID',width: 80},
                { field: 'o.code', title: '金融代码',width: 100},
                { field: 'o.companyName', title: '公司名称',width: 120},
                { field: 'o.annex', title: '附件',width: 150},
                { field: 'o.annexOtherName', title: '附件别名',width: 150},
                { field: 'o.annexUrl', title: '附件URL',width: 300},
                {
                    field: 'o.externalUrl', title: '外网URL', width: 280, formatter: function (value, row, index) {
                        if(value == undefined){
                            return "";
                        }else{
                            return '<a href="'+value+'" target="_blank">'+value+'</a>';
                        }
                    }
                },
                { field: 'o.title', title: '标题',width: 150},
                { field: 'o.context', title: '内容',width: 300},
                { field: 'o.tipIndexFlag', title: '是否主页使用',width: 120,formatter: function(value,row,index){
                        if (value=="1"){
                            return "是";
                        } else if(value=="0"){
                            return "否";
                        }
                        return value;
                    }},
                { field: 'u.realName', title: '创建人',width: 100},
                { field: 'o.createTime', title: '创建时间',width: 150}]],
            _order:"o.createTime desc",
            _append: [],//隐藏列
            _page: page_list,
            _table: "bs_news as o left join bs_user as u on o.createBy = u.id ",
            _exportTitle: "新聞消息列表",
            _context_handle: [{
                text: "详情",
                icon: "icon-info",
                handle: function(index,row){
                    j_showWin({url:'logistics/news/info.html?keyId='+this.getFieldValue(row,"o.id"),
                        title:'新闻信息',
                        iconCls: 'icon-form-info'})
                }
            },{
                text: "编辑",
                icon: "icon-edit",
                handle: function(index,row){
                    j_showWin({url:'logistics/news/edit.html?keyId='+this.getFieldValue(row,"o.id"),title:'编辑新聞消息',iconCls: 'icon-form-edit'})
                }
            },{
                text: "删除",
                //auth: "delete",
                icon: "icon-config-delete",
                handle: function(index,row){
                    var grid = $(this);
                    var self = this;
                    $.messager.confirm('系统提示', '您确认删该新聞消息吗?', function(r){
                        if (r){
                            self.focus();
                            showLoading();
                            fy_api.ajax({
                                url: "news/delete.do?_t="+new Date().getTime(),
                                data: {"keyId":self.getFieldValue(row,"o.id")},
                                success: function(data){
                                    hideLoading();
                                    if(isSuccess(data)){
                                        j_tip(data.msg,'success');
                                        grid.datagrid("reload");
                                    }else{
                                        $.messager.alert('系统提示',data.msg,'error',function(){
                                            self.focus();
                                        });
                                    }
                                }
                            });
                        }else{
                            self.focus();
                        }
                    });
                }
            }],
            toolbar: '#grid_toolbar',
            searchDiv: '#grid_search'
        });

        $("#btnBatchDelete").click(function(){
            initBatchDelete(grid_get("grid"),"news/batchDelete.do");
        });

        $('#company').inputgrid({
            idField: 'o.code',
            textField: 'o.name',
            searchField: ['o.code', 'o.name'],//查询字段多字段匹配
            columns: [[
                {field: 'o.code', title: '金融代码'},
                {field: 'o.name', title: '名称'},
                {field: 'o.address', title: '地址'}
            ]],
            _page: parent.page_list,
            _append: [],//隐藏列
            _table: "company as o",
            _db: "slave"
        });
    });

</script>
<div id="grid_search" data-options="region:'north',height:'auto',hideExpandTool: true,hideCollapsedContent: false,collapsedContent:function(){return '查询条件(已隐藏)'}" style="border-top:none;border-left:none;border-right:none;" class="search-form">
    <input type="hidden" name="o.deleteFlag" value="0"/>
    <div class="div-item">
        <div class="div-label">标题：</div>
        <input name="o.title" type="text" clear/>
    </div>
    <div class="div-item">
        <div class="div-label">金融代码：</div>
        <input name="o.code" type="hidden" id="code" clear/>
        <input type="text" id="company" clear/>
    </div>
</div>
<div data-options="region:'center',title:false,border:false" id="divCenter" style="">
    <table id="grid"></table>
</div>
<div id="grid_toolbar" style="padding:3px;">
    <a href="javascript:void(0)" class="easyui-linkbutton <!--auth-button-->" action="add" data-options="plain:true,iconCls:'icon-config-add'" onclick="j_showWin({url:'logistics/news/edit.html',title:'添加新聞消息',iconCls: 'icon-form-add'})">添加</a>
    <a href="javascript:void(0)" class="easyui-linkbutton <!--auth-button-->" action="delete" data-options="plain:true,iconCls:'icon-config-delete'" id="btnBatchDelete">批量删除</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'layout-button-up'" onclick="var button=$(this);if(button.linkbutton('options').iconCls=='layout-button-up'){$('body').layout('collapse','north');button.linkbutton({iconCls:'layout-button-down'})}else{$('body').layout('expand','north');button.linkbutton({iconCls:'layout-button-up'})}button.linkbutton('disable');setTimeout(function(){button.linkbutton('enable');},200)" style="float:right"></a>
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-help'" id="help" style="float:right"></a>
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-button-refresh'" onclick="grid_get('grid')[0].search(true)" style="float:right">重置</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-search'" onclick="grid_get('grid')[0].search()" style="float:right">查询</a>
</div>